<template>
    <div>
        <div v-if="isWx">
            <button class="btn" @click="userAuthorization">获取微信授权信息</button><br><br><br>
            <button class="btn" @click="userPayment">唤起微信支付</button>
        </div>

        <div v-else>
            <button class="btn" @click="userAuthorization">获取支付宝授权信息-</button><br><br><br>
            <button class="btn" @click="userPayment">唤起支付宝支付-</button>
        </div>
        <div @click="upAliPage">唤起支付宝卡劵页面</div>
    </div>
</template>

<script>
    import { getUserInfo,wakeUpPayment } from '@/modules/yd-service/index'
    import { getUrlParam } from '@/config/mUtils'
    export default {
        name : "index",
        data() {
            return {
                pageName: '首页',
                isWx : false
            };
        },
        mounted(){
            this.init();
        },
        methods : {
            upAliPage(){
                window.location.href = "alipays://platformapi/startapp?appId=68687143&url=%2Fwww%2Findex.html%3FuserId%3D2088312738817880%26templateId%3D2019082916525062910201367%26asd%3Dkkk"
            },
            init(){
                if(navigator.userAgent.indexOf('AlipayClient') > -1){
                    this.isWx = false;
                }else{
                    this.isWx = true;
                }
            },
            userPayment(){
                let o = {
                    "runMethod" : "wakeUpPayment",
                    "tranderNumber" : "23428918312",
                    "price" : "25.00"
                }
                wakeUpPayment(o).then(res =>{
                    console.dir("h5信息--唤起支付成功");
                }).catch(err => {
                    console.dir(err);
                });
            },
            userAuthorization(){
                var that = this;
                let o = {
                    "runMethod" : "getAuthorization"
                }
                getUserInfo(o).then(res =>{
                    if(res.code == "200"){
                        alert(JSON.stringify(res));
                    }
                }).catch(err => {
                    console.dir(err);
                });
            }
        }
    }
</script>

<style>

    html,body{
        background-color:#ffffff;
    }

    .btn{
        width:100px;
        height: 45px;
        border-radius: 5px;
        line-height: 45px;
        text-align: center;
        color:#ffffff;
        border:none;
        background-color: green;
    }

</style>
